<?php
// $Id$

/**
 * Controller_Admin_Web 控制器
 */
class Controller_Admin_live extends Controller_Abstract {
	

	//课程
	function actionapply(){
		$append = array("acct_id"=>$_SESSION['acct']['id']);
		$this->union_table = liveapply::meta();
		$this->lists($append);
	}
	function actionAdd(){

		if ($this->_context->isGET()) {
			# code...
			if($this->_context->id){
				$info = liveapply::find("id = ?",$this->_context->id)->getOne();
				$this->_view['info']=$info;
			}
		}
		
	    else{
	    	if($this->_context->id){
	    		$live = liveapply::find(array("id"=>$this->_context->id))->getOne();
				$live->apply_name=$this->_context->apply_name;
				$live->title=$this->_context->title;
				$live->status=$this->_context->status;
				$live->apply_msg = $this->_context->apply_msg;
				$live->tel=$this->_context->tel;
				$live->pic=$this->_context->pic;
				$live->dec=$this->_context->dec;
		
				$live->save();
				$end_time = strtotime($this->_context->end_time);
			
				$teacher = teacher::find('user_id = ?',$live->user_id)->getOne();
				if(!$teacher->id()){
				    $this->error('未找到申请的主播');
				}
				if($this->_context->status==99){
					//同步直播间信息
					liveapply::synclive($live,$teacher,$end_time);
				}
	    	}


	        Syslog::logs ( '直播审核信息,id :' . $live->id );
	        $this->success('设置成功');
	    }
	}
	function actiondetail(){

	}

	function actionDel(){
		Syslog::logs("删除直播申请，ID：".print_r($this->_context->ids,true));
	    $this->union_table = liveapply::meta();
	    $this->delete(array('id'=>$this->_context->ids));
	}
	

}


